package operation;

import book.Book;
import book.BookList;

import java.util.Scanner;

public class SupportBook implements IOPeration{
    @Override
    public void work(BookList bookList){
        Scanner scan = new Scanner(System.in);
        System.out.println("请输入你要支持的图书书号:");
        String id0 = scan.next();
        //用于记录支持图书的索引位置
        int num = -1;
        for (int i = 0; i < bookList.books.size(); i++) {
            //检查是否有该书号的书
            Book Book = bookList.books.get(i);
            if (Book.id.equals(id0)) {
                num = i;
                System.out.println(Book);
            }
        }
        if(num == -1){
            System.out.println("未找到该书号的书");
            return;
        }
        Book Book = bookList.books.get(num);
        Book.setHot(Book.getHot() + 100);
        bookList.books.set(num,Book);
        System.out.println("支持成功~");
    }
}
